<style scoped>
  .weui-media-box_appmsg .weui-media-box__hd {
    font-size: 12px;
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 50%;
    background: blue;
    color: #fff;
  }
  .weui-media-box_appmsg .weui-media-box__hd.gray {
    background: #ccc;
  }
  .weui-media-box__desc {
    font-size: 12px;
  }
  .weui-media-box__title {
    white-space: normal;
    font-size: 14px;
    margin-bottom: 5px;
  }
  .weui-form-preview__bd {
    text-align: left;
  }

  .weui-form-preview {
    position: relative;
    background-color: #fff;
    margin: 1%;
    border-radius: 5px;
  }
  .time {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 10px;
    color: #ccc;
  }

  .attachimg {
    width: 14px;
    height: 14px;
  }
  .imgicon {
    position: absolute;
    right: 0;
    bottom: 0;
  }
</style>
<template>
  <div class="logs">
    <div style="overflow:auto;overflow-x: hidden;" v-show="nodes.length > 0">
      <div class="weui-cells__title">审批记录</div>
      <div class="weui-form-preview" v-for="(item, index) in nodes">
        <div class="weui-form-preview__bd">
          <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
            <div class="weui-media-box__hd" :class="item.status == 2 ? 'gray' : ''" style="overflow: hidden;">
              {{item.name}}
            </div>
            <div class="weui-media-box__bd" style="position: relative;">
              <p class="time">{{filterNull(item.logs).createtime}}</p>
              <h4 class="weui-media-box__title" v-if="item.operators.length <= 1" v-for="(oper, i) in item.operators">{{oper.realname}}</h4>
              <h4 class="weui-media-box__title" v-if="item.operators.length > 1"><span v-for="(oper2, i) in item.operators">{{oper2.realname}}<i v-show="i+1 != item.operators.length"> / </i></span></h4>
              <p class="weui-media-box__desc">{{filterNull(item.logs).description}}</p>
              <div class="exp uploaderFiles" style="display: inline-block;" v-if="item.logs != null && item.logs.imgs.length > 0">
                <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in item.logs.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />
              </div>
            </div>
          </a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OperationLogs2',
  data () {
    return {
      nodes: [],
    }
  },
  props: [
    'orderid',
    'srguid',
    'departid',
  ],
  watch: {
    'orderid': function (val) {
      this.getOperatelogs();
    },
    'srguid': function (val) {
      this.getOperatelogs();
    },
    // 'departid': function (val) {
    //   console.log('departid:', this.departid)
    //   this.getOperatelogs();
    // },
  },
  methods: {
    getOperatelogs: function (id) {
      if (this.orderid == undefined || this.srguid == undefined || this.departid == undefined) return;
        this.axios({
          method: 'get',
          url: '/sales/Flowtempnode!getFlowNodes.action',
          params: {guid: this.orderid, srguid: this.srguid, departid: this.departid}
        }).then(response => {
          if (response.data.msg == 'success') {
            let data = response.data;
            //this.$nextTick(function () {
              this.nodes = data.nodes;
              console.log('nodes:', this.nodes)
              console.log('nodes.length:', this.nodes.length)
            //})
          } else {
            //this.toastError('获取审批记录失败');
          }
        });
    },
    filterNull: function (obj) {
      return obj != null ? obj : {};
    }
  }
}
</script>
